//
//  main.c
//  VideoParse
//
//  Created by xiaerfei on 2019/12/6.
//  Copyright © 2019 erfeixia. All rights reserved.
//
/*
 FLV MP4 TS
 
 H264 AAC PCM
 
 AAC格式简介：https://blog.csdn.net/leixiaohua1020/article/details/11822537
 
 流媒体协议
 
 RTP RTCP RTMP RTSP HTTP-FLV SIP HLS
 
 
 */
#include <stdio.h>
#include <string.h>
#include "flv.h"

struct InitMember {
    int first;
    double second;
    float third;
    float four;
};

typedef struct AVProbeData {
    const char *filename;
    unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
    int buf_size;       /**< Size of buf except extra allocated bytes */
    const char *mime_type; /**< mime_type, when known. */
} AVProbeData;

#define URL_SCHEME_CHARS                        \
"abcdefghijklmnopqrstuvwxyz"                \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"                \
"0123456789+-."

size_t av_strlcpy(char *dst, const char *src, size_t size)
{
    size_t len = 0;
    while (++len < size && *src)
        *dst++ = *src++;
    if (len <= size)
        *dst = 0;
    return len + strlen(src) - 1;
}
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))

void url_find_protocol(const char *filename) {
    char proto_str[128], proto_nested[128], *ptr;
    size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
    printf("%c",filename[proto_len]);
    av_strlcpy(proto_str, filename,
    FFMIN(proto_len + 1, sizeof(proto_str)));
    printf("%s",proto_str);
}

int main(int argc, const char * argv[]) {
    flv_parse_begin("/Users/xiaerfei/Documents/ffmpegDemo/res/cuc_ieschool.flv");
    
    struct InitMember test = { 10, -10.5, 3.6};
    AVProbeData pd = { "filename", NULL, 0 };
    printf("--->");
    url_find_protocol("rtmp:xxxxxx");
    return 0;
}
